package com.cxs.musicplaywidget;

import com.cxs.musicplaywidget.commonevent.NotificationManager;
import com.cxs.musicplaywidget.data.EventParam;
import com.cxs.musicplaywidget.service.idl.MyAgentStub;
import com.cxs.musicplaywidget.util.LogUtils;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.rpc.IRemoteObject;

public class ServiceAbility extends Ability {
    private static final String tag = ServiceAbility.class.getSimpleName();
    private  NotificationManager notificationManager = null;
    @Override
    protected void onStart(Intent intent) {
        LogUtils.debug(tag, "onStart");
        notificationManager = NotificationManager.getInstance(this);
        notificationManager.sendNotification(new EventParam(EventParam.EventAction.CONNECTED));
    }

    @Override
    public IRemoteObject onConnect(Intent intent) {
        return new MyAgentStub(this);
    }

    @Override
    public void onDisconnect(Intent intent) {
        notificationManager.cancelNotification();
    }
}